package neg;

import java.io.Serializable;

import org.openstreetmap.gui.jmapviewer.Coordinate;

public class Ubicacion extends Coordinate implements Serializable {

	private static final long serialVersionUID = 1L;

	public Ubicacion(double longitud, double latitud) {
		super(latitud, longitud);
	}

	public Coordinate getCordenada() {
		return new Coordinate(this.getLat(), this.getLon());
	}

	public double distancia(Ubicacion otra) {
		return Math.sqrt(Math.pow((this.getLat() - otra.getLat()), 2)
				+ Math.pow((this.getLon() - otra.getLon()), 2));
	}

	@Override
	public String toString() {
		return getLon() + " " + getLat();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(getLat());
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(getLon());
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null || !(obj instanceof Ubicacion))
			return false;
		Ubicacion other = (Ubicacion) obj;
		if (Double.doubleToLongBits(getLat()) != Double.doubleToLongBits(other
				.getLat()))
			return false;
		if (Double.doubleToLongBits(getLon()) != Double.doubleToLongBits(other
				.getLon()))
			return false;
		return true;
	}

}
